/*
提交链接：https://leetcode.cn/problems/min-cost-climbing-stairs/description/
 746. 使用最小花费爬楼梯
 王顶成 2024/9/16
*/

class Solution {
public:
    int minCostClimbingStairs(vector<int>& cost) {
        int high=cost.size();
        vector<int> a(high+1);
        //dp[i]=min(i-1,i-2)
        a[0]=a[1]=0;
        int k=0;
        for(int i=2;i<=high;i++){
            a[i]=min(a[i-1]+cost[i-1],a[i-2]+cost[i-2]);
        }
        return a[high];
    }
};